﻿namespace RailEurope.Cockpit
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Collections.Specialized;

    public partial class TestEmailPage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void btnFireEmail_Click(object sender, EventArgs e)
        {
            try
            {
                string emailbody = GetEmailBody2();

                string mailFrom = "anjum.rizwi@valtech.co.in";
                string toEmailAddress = "anjum.rizwi@valtech.co.in";
                string mailSubject = "Test Email: ContactUsEnquiryReply.ascx";

                EmailHelper.SendMail(toEmailAddress, mailFrom, string.Empty, string.Empty, mailSubject, emailbody, null);

                lblMsg.Text = "Successfully sent at " + DateTime.Now.ToString();
            }
            catch (Exception ex)
            {
                lblMsg.Text = ex.ToString();
            }
        }

        public string GetEmailBody()
        {
            string controlFilePath = "EmailTemplate/ContactUsEnquiryReply.ascx";
            NameValueCollection nvc = new NameValueCollection();

            nvc.Add("CustomerName", "Kiran");
            nvc.Add("EnquiryId", "12");
            nvc.Add("TimeAdded", DateTime.Now.ToShortDateString());
            nvc.Add("UserName", "anjum.rizwi");
            nvc.Add("ThreadContent", "Dummy:The sender does not accept liability for errors or omissions arising as a result of email transmission or its interception.");
            nvc.Add("ViewEnquiryURL", "http://public.web.upgrade.test.enh/default.aspx?tabid=1543");

            nvc.Add("EmailSignature", "Software Developer");

            string emailbody = UIHelper.RenderUserControl(controlFilePath, nvc);

            return emailbody;
        }

        public string GetEmailBody2()
        {
            string controlFilePath = "EmailTemplate/ContactUsEnquiryReply.ascx";

            EnquiryThread th = new EnquiryThread();
            th.CustomerName = "Kiran";
            th.EnquiryId = "12";
            th.TimeAdded = DateTime.Now.ToLongDateString();
            th.UserName = "anjum.rizwi";
            th.ThreadContent = "Dummy:The sender does not accept liability for errors or omissions arising as a result of email transmission or its interception.";
            th.ViewEnquiryURL= "http://public.web.upgrade.test.enh/default.aspx?tabid=1543";
            th.EmailSignature= "Software Developer";

            string emailbody = UIHelper.RenderUserControl(controlFilePath, th);

            return emailbody;
        }
    }
}